﻿@model Orion.Models.HomeIndexViewModel
@{
    ViewBag.Title = "IRIS - Innranet - Allar fréttir";
    Layout = "~/Views/Shared/_WorkLayout.cshtml";
}

<section id="main_content">
<h1>Allar fréttir</h1>


     <table>
        <caption></caption>
        <thead>
            <tr>
                <td>Dagsetning</td>
                <td>Titill</td>
            </tr>
        </thead>
        <tbody>    
            @foreach (var n in Model.NewsArticle)
            {
                DateTime temp = n.ContentDate;
                <tr>
                    <td>@temp.ToString("dd MMMM yyyy")</td>
                    <td>@Html.ActionLink( n.Title, "ViewNews/"+@n.ID, "WorkNewsArticle" )</td>


                    @if( Roles.IsUserInRole("Admin") )
                    {
                        <td>@Html.ActionLink("Breyta", "EditNews/" + @n.ID, "WorkNewsArticle")</td>
                    }
                    
                    @if (n.Valid == true)
                    {
                        if( Roles.IsUserInRole( "Admin" ) )
                        {
                            <td>@Html.ActionLink("Eyða", "DisableNewsArticle/" + @n.ID, "WorkNewsArticle", new { onclick = "return confirm('Ertu viss um að þú viljir eyða fréttinni?')" })</td>
                        }
                    }
                    else
                    {
                        if ( Roles.IsUserInRole( "Admin" ) )
                        {
                            <td>@Html.ActionLink("Birta", "EnableNewsArticle/" + @n.ID, "WorkNewsArticle", new { onclick = "return confirm('Ertu viss um að þú viljir birta fréttina?')" })</td>
                        }
                    }
                </tr>
            }         
        </tbody>
    </table>
</section>